import 'package:flutter/material.dart';
import 'package:znmm/UI/Kline_Demo/MarketItem.dart';

class MarketItemWidget extends StatelessWidget {
  final MarketItem item;

  const MarketItemWidget({super.key, required this.item});

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: Text(
        item.name,
        style: const TextStyle(fontWeight: FontWeight.bold),
      ),
      title: Text(
        item.currentPrice.toString(),
        style: TextStyle(
          color: item.isRising ? Colors.red : Colors.green,
          fontWeight: FontWeight.bold,
        ),
      ),
      subtitle: Text(
        "${item.change.toStringAsFixed(5)} (${item.percentageChange.toStringAsFixed(2)}%)",
        style: TextStyle(
          color: item.isRising ? Colors.red : Colors.green,
        ),
      ),
      trailing: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text("买价: ${item.buyPrice}"),
          Text("卖价: ${item.sellPrice}"),
        ],
      ),
    );
  }
}
